package com.yhq.sensitive.strategy;

import com.yhq.sensitive.enums.SensitiveDefaultLengthEnum;
import com.yhq.sensitive.util.SensitiveUtils;

/**
 * 身份证号脱敏
 *
 * @author yhq
 * @date 2021年9月6日 16点13分
 **/
public class SensitiveIdCard implements IStrategy {

    @Override
    public String desensitization(String idCardNum, int begin, int end) {
        if (begin != SensitiveDefaultLengthEnum.ID_CARD.getBegin() && begin != 0 &&
                end != SensitiveDefaultLengthEnum.ID_CARD.getEnd() && end != 0) {
            return SensitiveUtils.idCard(idCardNum, begin, end);
        }
        return SensitiveUtils.idCard(idCardNum, SensitiveDefaultLengthEnum.ID_CARD.getBegin(), SensitiveDefaultLengthEnum.ID_CARD.getEnd());
    }

}
